package org.jadapter.tests;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.Map;

import org.jadapter.Adapter;
import org.jadapter.JAdapter;
import org.jadapter.tests.examples.AmbiguousAdapter;
import org.jadapter.tests.examples.CommaSeparated;
import org.junit.Test;

public class TestAmbiguousAdapter {

    @Test public void shouldFindTheCorrectConstructor() {
        Map<String, String> map;  
        map = new HashMap<String,String>(){{
            put("Foo", "foo");
            put("Bar", "bar");
        }};   
        
        Adapter<CommaSeparated,Map> adapter = 
            new JAdapter<CommaSeparated,Map> (AmbiguousAdapter.class)
                .from(Map.class).to(CommaSeparated.class);                      

        CommaSeparated commas = adapter.transform(map);

        String listCs = commas.getCommaSeparated();
        assertEquals("Adapter using extra vararg constructor", "Foo:foo,Bar:bar", listCs);
        
    }
    
}
